package com.gmt.controller;

import com.gmt.pojo.User;
import com.gmt.service.IUserService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * @author John.zhang
 * @version Id: UserController, v 1.0 2020/11/12 17:48 ZhiYong Exp $
 */
@Controller
public class UserController {

    @Resource
    private IUserService service;

    @RequiresRoles(value = {"roleA"},logical = Logical.OR)
    @RequestMapping("/user/queryA")
    public String query(Model model) {
        model.addAttribute("list", service.query(new User("root")));
        return "user";
    }

    @RequiresRoles(value = {"roleB"})
    @RequestMapping("/user/queryB")
    public String queryB(Model model){
        model.addAttribute("list",service.query(new User("root")));
        return "user";
    }

}
